package com.bookshop.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/test",
        initParams = {
        @WebInitParam(name = "schoolName",value = "长沙科泰梦想学院"),
                @WebInitParam(name = "className",value = "T161黄埔精英班")
        })
public class TestServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String encoding = this.getServletContext().getInitParameter("encoding");

        System.out.println("上下文参数字符编码："+encoding);
        req.setCharacterEncoding(encoding);

        ServletConfig servletConfig = this.getServletConfig();
        String schoolName = servletConfig.getInitParameter("schoolName");
        String className=servletConfig.getInitParameter("className");

        System.out.println(schoolName);
        System.out.println(className);



    }
}
